﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CNKI.TPI.Web.Search.Model;
using CNKI.TPI.Web.Base;

namespace CNKI.TPI.Web.Search.IDAO
{
    public interface IUserDBDAO
    {
        /// <summary>
        /// 获得发布字段
        /// </summary>
        /// <param name="dbID"></param>
        /// <param name="fieldType"></param>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE_PUBLISH_FIELD> GetPublishField(int dbID, FieldType fieldType, PermissionOption option = PermissionOption.FilteringPermissions);

        /// <summary>
        /// 获得跨库检索查询条件字段
        /// </summary>
        /// <param name="dbID"></param>
        /// <param name="fieldType"></param>
        /// <returns></returns>
        IList<DBUSFIELD> GetUnionPublishField();
        /// <summary>
        /// 获得跨库检索查询条件字段
        /// </summary>
        /// <param name="dbID"></param>
        /// <param name="fieldType"></param>
        /// <returns></returns>
        IList<DBUSFIELD> GetUnionFieldList(FieldType type);

        /// <summary>
        /// 获得跨库检索查询数据库
        /// </summary>
        /// <param name="dbID"></param>
        /// <param name="fieldType"></param>
        /// <returns></returns>
        IList<DBCONFIG> GetUnionDB(string classCode = null);

        /// <summary>
        /// 单库检索
        /// </summary>
        /// <param name="dbID"></param>
        /// <param name="select"></param>
        /// <param name="where"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        DataSet SingleSearch(int dbID, string select, string where, string strGroup, string strOrder, int pageIndex, int pageSize, PermissionOption option = PermissionOption.FilteringPermissions, bool enableCache = true);

        /// <summary>
        /// 获取文件
        /// </summary>
        /// <param name="recordID"></param>
        /// <param name="dbName"></param>
        /// <returns></returns>
        IList<METADATA_FILE> GetFile(int recordID, string dbName);

        /// <summary>
        /// 获取文件
        /// </summary>
        /// <param name="FileID"></param>
        /// <param name="dbName"></param>
        /// <returns></returns>
        METADATA_FILE GetSingleFile(int FileID, string dbName);

        /// <summary>
        /// 获取图样采样
        /// </summary>
        /// <param name="FileID"></param>
        /// <param name="dbName"></param>
        /// <returns></returns>
        METADATA_FILE_IMAGE GetSmallPic(int FileID, string dbName);

        /// <summary>
        /// 重载多库查询
        /// </summary>
        /// <param name="strdbID"></param>
        /// <param name="select"></param>
        /// <param name="where"></param>
        /// <param name="strGroup"></param>
        /// <param name="strOrder"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        DataSet MultiSearch(IList<SYS_CMS_DATABASE> dbList, string select, string where, string strGroup, string strOrder, int pageIndex, int pageSize, string classCode);

        /// <summary>
        /// 获得跨库检索分类
        /// </summary>
        /// <returns></returns>
        IList<DBCLASS> GetUnionClass();

        /// <summary>
        /// 获得数据库列表
        /// </summary>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE> GetDatabaseList();

        /// <summary>
        /// 获得数据库列表
        /// </summary>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE> GetDatabaseList(int pageIndex, int pageSize, out int count);
         /// <summary>
        /// 根据数据库名称获得数据库列表
        /// </summary>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE> GetDatabaseList(int pageIndex, int pageSize, out int count, string dbname, IList<SearchType> SearchTypeList = null);

        int[] GetUserDownloadInfo(int dbID, string userID);
         /// <summary>
        /// 根据用户ID和时间段获取检索词
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="startdate"></param>
        /// <param name="enddate"></param>
        /// <returns></returns>
        string GetQueryByUserCode(string userCode);

         /// <summary>
        /// 删除METADATA 记录
        /// </summary>
        /// <param name="sysid"></param>
        /// <param name="dbCode"></param>
        /// <returns></returns>
        bool DelMetaData(int sysid, string dbCode);

        /// <summary>
        /// 更新METADATA 记录
        /// </summary>
        /// <param name="sysid"></param>
        /// <param name="dbCode"></param>
        /// <returns></returns>
        bool UpdateMetaData(string sysid, string dbCode, Dictionary<string, object> fieldList, bool isUnicode);

        /// <summary>
        /// 插入METADATA 记录
        /// </summary>
        /// <param name="sysid"></param>
        /// <param name="dbCode"></param>
        /// <returns></returns>
        int InsertMetaData(string dbCode, Dictionary<string, object> fieldList, bool isUnicode);
		
        /// <summary>
        /// 得到满足条件的结果集的记录数---LZG添加
        /// </summary>
        /// <param name="Sql">Sql语句</param>
        /// <returns>记录数目</returns>
        IList<SYS_CMS_SUBMIT> GetSubmitConfig(string Sql);

        DataTable IsOnlyOne(string strDbCode, string strField, string strFieldValue);
		
		/// <summary>
        /// 返回DataTable类型信息---LZG添加
        /// </summary>
        /// <param name="strSql"></param>
        /// <returns></returns>
        DataTable GetDataTableBySql(string strSql);

        /// <summary>
        /// 返回DataTable类型信息---LZG添加
        /// </summary>
        /// <param name="strSql"></param>
        /// <returns></returns>
        DataTable GetDataTableBySql(string strSql, int pageIndex, int pageSize, out int count, IList<SYS_CMS_DATABASE> selectDbList = null);

		         /// <summary>
        /// 获得论文提交数据库列表---LZG添加
        /// </summary>
        /// <param name="Flag"></param>
        /// <returns></returns>
        IList<SYS_CMS_OPTION> GetSubmitDBList(int Flag);

        /// <summary>
        /// 获得汉字拼音配置信息---LZG添加
        /// </summary>
        /// <param name="dbcode"></param>
        /// <returns></returns>
        IList<SYS_CMS_HZTOPY> GetPYHZList(string dbcode);

        IList<SYS_CMS_SUBMIT> GetSubmitConfig(string dbcode, string fieldname, SubmitFieldType fieldType);

        int GetFileCount(string dbcode, string fileName, int sysid = -1);

        int UpdateUploadFileDate(string dbcode, string fileName);

        int InsertUploadFile(string dbcode, METADATA_FILE content);

        int UpdateUploadFileDOISortNo(string dbcode, int fileID, string doi, string sortNo);

        int UpdateFileInfo(string dbcode, string fileName, int id);

        IList<SYS_CMS_MEMBER_UNIT> GetMember_Unit();

        bool DeleteFileInfo(string dbcode, string fileName, int id);

        int ExecSql(string strSql, bool isUnicode);

        int UpdateMetaFileLink(string dbcode, int oldRecID, int newRecID);

        DataTable GetMetaInfo(string dbcode, int sysid);

        int UpdateMetaInfo(string dbcode, int sysid, string addDate, string digitFileName);
        /// <summary>
        ///根据数据库ID(逗号分隔多个)获取数据库列表
        /// </summary>
        /// <param name="strdataID">多个数据库ID</param>
        /// <returns></returns>
        IList<SYS_CMS_DATABASE> GetDBByID(string strdataID);

        bool SaveFile(string srcFile, string targetFile);

        bool DeleteFile(string filePath);

        IList<SYS_CMS_DATABASE_RELATION> GetSimilarList(string dbCode);
    }
}
